<?php

class User_dynamicController extends BaseController {

	public function selfListAction() {
		$uid = $this->user_info['uid'];
		$page = intval(Request::getParams('page', 1));
		$user_type = intval(Request::getParams('user_type', 1));
		$pageSize = intval(Request::getParams('pageSize', 10));
		$where = $value = [];
		$where[] = 'uid=? and user_type=?';
		$value[] = $uid;
		$value[] = $user_type;
		$order = 'dynamic_id desc';
		Response::ajax(200, 'success', self::model('dynamic')->getList($where, $value, $order, $page, $pageSize));
	}

	public function followListAction() {
		$uid = $this->user_info['uid'];
		$pageSize = intval(Request::getParams('pageSize', 10));
		$lastDynamicId = Request::getParams('lastDynamicId');
		if (!$lastDynamicId) {
			$lastDynamicId = 130000000;
		}
		$where = $value = [];
		$where[] = 'd.status=? and r.uid=?';
		$value[] = 1;
		$value[] = $uid;
		if ($lastDynamicId) {
			$where[] = 'd.dynamic_id<=?';
			$value[] = $lastDynamicId - 1;
		}
		Response::ajax(200, 'success', self::model('dynamic')->getListWithRelate($where, $value, $lastDynamicId, $pageSize));
	}
}